home *** CD-ROM | disk | FTP | other *** search
/ NeXT Enterprise Objects Framework 1.1 / NeXT Enterprise Objects Framework 1.1.iso / NextDeveloper / Examples / EnterpriseObjects / DistributedEO / Employee.m < prev    next >
Encoding:
Text File  |  1995-02-17  |  1.6 KB  |  69 lines

  1. // Employee.m
  2. //
  3. // Created on Fri Jan 13 15:56:20 PST 1995 by NeXT EOModeler.app Version 71
  4. /*
  5.    modified by enoyau
  6.  
  7.    You may freely copy, distribute, and reuse the code in this example.
  8.    NeXT disclaims any warranty of any kind, expressed or implied, as to its
  9.    fitness for any particular use.
  10. */
  11.  
  12. #import "Employee.h"
  13. #import <appkit/NXImage.h>
  14.  
  15. @implementation Employee
  16. static NSString *localLockString;
  17.  
  18. + (void)setLocalLockString:(NSString *)lockString
  19. {
  20.     if(localLockString) [localLockString autorelease];
  21.     localLockString = [lockString copy];
  22. }
  23.  
  24. - (NSString *)lock { return lock; }
  25.  
  26. - (void)dealloc
  27. {
  28.     [address autorelease];
  29.     [city autorelease];
  30.     [first_name autorelease];
  31.     [hire_date autorelease];
  32.     [last_name autorelease];
  33.     [phone autorelease];
  34.     [state autorelease];
  35.     [zip autorelease];
  36.     [toJob_Title autorelease];
  37.     [toEmp_Photo autorelease];
  38.     [photo autorelease];
  39.     [lock autorelease];
  40.     [super dealloc];
  41. }
  42.  
  43. // Determine if the EO is editable by comparing the local lock string with
  44. // the EO lock string stored in the database.
  45. - (BOOL)isEditable
  46. {
  47.     return [[self lock] isEqual:localLockString];
  48. }
  49.  
  50. - (BOOL)isLocked
  51. {
  52.     return ![[self lock] isEqual:[EONull null]];
  53. }
  54.  
  55. // lockImage is an attribute added to the Employee entity in InterfaceBuilder.
  56. // This method retrieves the proper lock image to be displayed in the
  57. // tableview.
  58. - lockImage
  59. {
  60.     if(![self isLocked])
  61.         return nil;
  62.     else if([self isEditable])
  63.         return [NXImage findImageNamed:"lock_h"];
  64.     else
  65.         return [NXImage findImageNamed:"lock"];
  66. }
  67.  
  68. @end
  69.